<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0"><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />   
        <title>Welcome to Design Zone......</title>
        <link rel="stylesheet" type="text/css" href="../../scripts/ext/resources/css/ext-all.css" />
        <link rel="stylesheet" type="text/css" href="../../styles/dzbase.css" />
        <script type="text/javascript" src="../../scripts/ext/adapter/ext-base.js">
        </script>
        <script type="text/javascript" src="../../scripts/ext/ext-all.js">
        </script>
        <script type="text/javascript" src="../../scripts/i18nMessage.js">
        </script>
        <script type="text/javascript" src="../../scripts/utils.js">
        </script>
        <script type="text/javascript">
        	var quMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.quotation');
            var message = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=message');
			
            Ext.onReady(function(){
                Ext.QuickTips.init();
                Ext.form.Field.prototype.msgTarget = 'side';
								
                var idValue = getPrarmeterValue(window.location, 'id');
                var startPage = getPrarmeterValue(window.location, 'startPage');
                var deliveryForm = new Ext.FormPanel({
                    labelAlign: 'left',
                    labelWidth: 120, 
                    url: '../../servlet/QuDeliveryServlet?action=1',
                    frame: true,
                    reader: new Ext.data.XmlReader({
                        record: 'item'
                    }, [{
                        name: 'id',
                        mapping: 'id'
                    }, {
                        name: 'transport',
                        mapping: 'transport'
                    }, {
                        name: 'port',
                        mapping: 'port'
                    }, {
                        name: 'airport',
                        mapping: 'airport'
                    }, {
                        name: 'comment',
                        mapping: 'comment'
                    }]),
                    title: quMessage.get('ui.quotation.editdelivery'),
                    bodyStyle: 'padding:5px 5px 5px 5px',
                    
                    items: [{
                        id: 'id',
                        name: 'id',
                        xtype: 'hidden'
                    },{
                        layout: 'column',
                        items: [{
                            columnWidth: .33,
                            layout: 'form',
                            items: [{
								id: 'transport',
                                name: 'transport',
                                fieldLabel: quMessage.get('ui.quotation.transport'),
                                xtype: 'textfield',
                                anchor: '86%',
								width: '90%',
								maxLength: 256,
                                allowBlank: false,
                                blankText: message.get('message.edit.noblank'),
                                maxLength: 64
                            }]
						
						},{
                            columnWidth: .33,
                            layout: 'form',
                            items: [{
								id: 'port',
                                name: 'port',
                                fieldLabel: quMessage.get('ui.quotation.port'),
                                xtype: 'textfield',
                                anchor: '86%',
								width: '90%',
								maxLength: 256,
                                maxLength: 64
                            }]
						
						},{
                            columnWidth: .33,
                            layout: 'form',
                            items: [{
    								id: 'airport',
                                    name: 'airport',
                                    fieldLabel: quMessage.get('ui.quotation.airport'),
                                    xtype: 'textfield',
                                    anchor: '86%',
    								width: '90%',
    								maxLength: 256,
                                    maxLength: 64
                                }]
						
						}]
					},{
                        fieldLabel: message.get('message.edit.comment'),
                        name: 'comment',
                        xtype: 'textarea',
                        maxLength: 1024,
						width: '90%',
                        maxLengthText: message.get('message.edit.toolong')
                    }],
                    
                    buttons: [{
                        text: message.get('message.edit.save'),
                        handler: function(){
                            if (deliveryForm.getForm().isValid()) {
                                //messageForm.hide();
                                deliveryForm.getForm().submit({
                                    method: 'post',
                                    success: function(form, action){
                                        //alert(form);
										
                                        messageTip.msg(message.get('message.tip'), message.get('message.edit.successful'));
                                        deliveryForm.getForm().reset();
                                        //messageForm.show();
                                    },
                                    failure: function(form, action){
                                        //alert(form);
                                        messageTip.msg(message.get('message.tip'), message.get('message.edit.unsuccessful'));
                                        //messageForm.show();
                                    }
                                });
                            }
                        }
                    },{
						text: message.get('message.edit.reset'),
						handler: function(){
							messageForm.getForm().reset();
						}
					}, {
                        text: message.get('message.edit.cancel'),
                        handler: function(){
                            if (startPage != null) {
                                window.location = 'delivery_list.html?startPage=' + startPage;
                            }
                            else {
                                window.location = 'delivery_list.html';
                            }
                        }
                    }]
                });
				
                deliveryForm.render('deliveryForm');
	
		
				if(idValue != null){
					document.getElementById('id').value = idValue;
					deliveryForm.getForm().load({url:'../../servlet/QuDeliveryServlet?action=3&id=' + idValue, waitMsg:Ext.LoadMask.prototype.msg});
				}
            });
			
			
        </script>
    </head>
    <body>
        <div id="deliveryForm"></div>
    </body>
</html>
